/*
 ============================================================================
 Name		: Container4.cpp
 Author	  : UMteam
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CContainer4 implementation
 ============================================================================
 */

#include <aknviewappui.h>
#include <eikappui.h>
#include <FinancialAssistant.rsg>
#include <eikgted.h>
#include "Container3.h"
#include "ContainerView3.h"
#include "FinancialAssistant.hrh"
#include <aknutils.h>
#include <akniconutils.h>
#include <FinancialAssistant.mbg>

_LIT(KBitmapPath, "\\resource\\apps\\FinancialAssistant.mbm");


CContainer3::CContainer3()
	{
	}


CContainer3::~CContainer3()
	{
	delete inavigateEdwin;
	delete iBackGround;
	}

CContainer3* CContainer3::NewL( 
		const TRect& aRect)
	{
	CContainer3* self = CContainer3::NewLC( 
			aRect);
	CleanupStack::Pop( self );
	return self;
	}


CContainer3* CContainer3::NewLC( 
		const TRect& aRect)
	{
	CContainer3* self = new ( ELeave ) CContainer3();
	CleanupStack::PushL( self );
	self->ConstructL( aRect );
	return self;
	}
			

void CContainer3::ConstructL( 
		const TRect& aRect )
	{
	CreateWindowL();


	inavigateEdwin=new(ELeave)CEikEdwin;
	inavigateEdwin->SetContainerWindowL(*this);
	inavigateEdwin->ConstructL(EAknEditorFlagDefault,20,150,20);
	//_LIT(hello,"I love China to you");
	//TBuf<256>buf(hello);	
	//inavigateEdwin->SetTextL(&buf);
	inavigateEdwin->SetSuppressBackgroundDrawing(ETrue );

//加载位图
	TFileName bitmapFile (KBitmapPath);
	User::LeaveIfError (CompleteWithAppPath (bitmapFile));	
	iBackGround = iEikonEnv->CreateBitmapL( bitmapFile,EMbmFinancialassistantHelp );
	
	SetRect( aRect );
	SetExtentToWholeScreen();
	ActivateL();
	}
			

TInt CContainer3::CountComponentControls() const
	{
	return 1;
	}

CCoeControl* CContainer3::ComponentControl( TInt aIndex ) const
	{
	switch ( aIndex )
		{
		case 0:
			return inavigateEdwin;
		default:return NULL;
		}
	}
				
void CContainer3::SizeChanged()
	{
	inavigateEdwin->SetExtent(TPoint(10,50),TSize(220,220));
	DrawDeferred();
	}

			
TKeyResponse CContainer3::OfferKeyEventL( 
		const TKeyEvent& aKeyEvent, 
		TEventCode aType )
	{
		if(aType!=EEventKey)
			{	
				return EKeyWasNotConsumed;	
			}
	//	if(inavigateEdwin->IsFocused())
			{
			if(aKeyEvent.iScanCode==EKeyUpArrow||
					aKeyEvent.iScanCode==EKeyDownArrow)
				{
				return inavigateEdwin->OfferKeyEventL(aKeyEvent,aType);
				}
			}
		return EKeyWasNotConsumed; 
	}
				
			
void CContainer3::Draw( const TRect& aRect ) const
	{
	    CWindowGc& gc = SystemGc();
		gc.SetPenStyle( CGraphicsContext::ENullPen );
		gc.SetBrushColor( TRgb(189,218,250) );
		gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
		gc.DrawRect( aRect );
		gc.DrawBitmap(Rect(),iBackGround);
	}
				
void CContainer3::HandleControlEventL(
	CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
	{
	// TODO: Add your control event handler code here
	}
